package com.xzzz.common.iaas;

import com.xzzz.common.iaas.alibaba.oss.OSSManager;
import com.xzzz.common.iaas.alibaba.sms.AliSmsManager;
import com.xzzz.common.iaas.huawei.obs.OBSManager;
import com.xzzz.common.iaas.qiniu.kodo.KODOManager;
import com.xzzz.common.iaas.tencent.cos.COSManager;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class IaasConfiguration {

    // region OS

    @Bean
    @ConditionalOnProperty(name = "xzzz.iaas.ostype", havingValue = "alibaba")
    public OSManager ossManager(IaasProperties iaasProperties) {
        return new OSSManager(iaasProperties);
    }

    @Bean
    @ConditionalOnProperty(name = "xzzz.iaas.ostype", havingValue = "huawei")
    public OSManager obsManager(IaasProperties iaasProperties) {
        return new OBSManager(iaasProperties);
    }

    @Bean
    @ConditionalOnProperty(name = "xzzz.iaas.ostype", havingValue = "tencent")
    public OSManager cosManager(IaasProperties iaasProperties) {
        return new COSManager(iaasProperties);
    }

    @Bean
    @ConditionalOnProperty(name = "xzzz.iaas.ostype", havingValue = "qiniu")
    public OSManager kodoManager(IaasProperties iaasProperties) {
        return new KODOManager(iaasProperties);
    }

    // endregion

    // region SMS

    @Bean
    public AliSmsManager aliSmsManager(IaasProperties iaasProperties) {
        return new AliSmsManager(iaasProperties);
    }

    // endregion
}
